<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>乐购商城 - 正品潮流电商平台</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
            font-family: "PingFang SC", "Helvetica Neue", Arial, sans-serif;
        }
        
        body {
            background-color: #f7f7f7;
            color: #333;
        }
        
        .header {
            background-color: #000;
            height: 80px;
            position: sticky;
            top: 0;
            z-index: 100;
        }
        
        .header-container {
            width: 1200px;
            margin: 0 auto;
            display: flex;
            align-items: center;
            height: 100%;
        }
        
        .logo {
            width: 120px;
            height: 40px;
            color: white;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 24px;
            font-weight: bold;
        }
        
        .search-box {
            margin-left: 40px;
            display: flex;
            width: 500px;
            background: #2a2a2a;
            border-radius: 20px;
            padding: 0 15px;
            height: 40px;
            align-items: center;
        }
        
        .search-input {
            flex: 1;
            height: 100%;
            padding: 0 10px;
            background: transparent;
            border: none;
            outline: none;
            color: #fff;
            font-size: 14px;
        }
        
        .search-input::placeholder {
            color: #999;
        }

        .search-box img {
            height: 20px;
            width: auto;
        }

        .search-btn {
            width: 20px;
            height: 20px;
            background: transparent;
            border: none;
            cursor: pointer;
            color: #999;
        }
        
        .nav {
            display: flex;
            margin-left: auto;
            align-items: center;
        }
        
        .nav-item {
            margin-left: 25px;
            font-size: 14px;
            position: relative;
        }
        
        .nav-item a{
            color: #fff;
            text-decoration: none;
            display: flex;
            flex-direction: column;
            align-items: center;
            font-size: 12px;
        }

        .nav-item i {
            font-size: 20px;
            margin-bottom: 5px;
        }

        .nav-item .cart-count {
            position: absolute;
            top: -5px;
            right: -8px;
            background: #ff2442;
            color: white;
            border-radius: 50%;
            width: 16px;
            height: 16px;
            font-size: 10px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
    </style>
</head>
<body>
    <div class="header">
        <div class="header-container">
            <div class="logo">乐购商城</div>
            <div class="search-box">
                <input type="text" class="search-input" id="input" placeholder="搜索商品、品牌" value="${page.keyWord }">
                <a href="/lego/selectGoods.do${url} " id="select">
                    <img src="image/d.png">
                </a>
                <button class="search-btn"><i class="fas fa-search"></i></button>
            </div>
            <div class="nav">
                <div class="nav-item">
                    <a href="selectGoods.do">
                        <i class="fas fa-home"></i>
                        <span>首页</span>
                    </a>
                </div>
                <div class="nav-item">
                    <a href="#">
                        <i class="fas fa-compass"></i>
                        <span>发现</span>
                    </a>
                </div>
                <div class="nav-item">
                    <a href="#">
                        <i class="fas fa-shopping-cart"></i>
                        <span>购物车</span>
                    </a>
                </div>
                <div class="nav-item">
                    <a href="/lego/personal.jsp">
                        <i class="fas fa-user"></i>
                        <span>我的</span>
                    </a>
                </div>
            </div>
        </div>
    </div>
</body>
<script>
	var searchLink = document.getElementById("select"); // 假设是<a id="search-link">

	searchLink.addEventListener('click', function(e) {
    	e.preventDefault(); // 阻止默认跳转
    	var keyWord = document.getElementById('input').value;
    	var newUrl = "/lego/selectGoods.do?keyWord=" + encodeURIComponent(keyWord);
    	window.location.href = newUrl; // 跳转
	});
</script>
</html>